package com.xone.xapp;

import java.util.List;

import org.json.JSONObject;

import android.widget.BaseAdapter;

public abstract class BasicListAdapter<T extends BasicListHolder> extends BaseAdapter {

	protected List<T> list;

	public abstract List<T> initWithJsonList(List<JSONObject> list);
	
	@Override
	public T getItem(int position) {
		if (null == list || list.isEmpty()) {
			return null;
		}
		return list.get(position);
	}
	
	/**
	 * 取得顶部第一个偏移的位置
	 * @return
	 */
	public abstract int getTopLastIndex();
	
	public List<T> getList() {
		return this.list;
	}

	@Override
	public int getCount() {
		if (null == list || list.isEmpty()) {
			return 0;
		}
		return list.size();
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

}
